<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LINE 1 &quot;libraries\\Win32\\System\\Win32\\Console.hsc&quot; #-}</span><span>
</span><span id="line-1"></span><span>
</span><span id="line-2"></span><span class="hs-pragma">{-# LINE 2 &quot;libraries\\Win32\\System\\Win32\\Console.hsc&quot; #-}</span><span>
</span><span id="line-2"></span><span class="hs-pragma">{-# LANGUAGE Safe #-}</span><span>
</span><span id="line-3"></span><span>
</span><span id="line-4"></span><span class="hs-pragma">{-# LINE 6 &quot;libraries\\Win32\\System\\Win32\\Console.hsc&quot; #-}</span><span>
</span><span id="line-6"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-7"></span><span class="hs-comment">-- |</span><span>
</span><span id="line-8"></span><span class="hs-comment">-- Module      :  System.Win32.Console</span><span>
</span><span id="line-9"></span><span class="hs-comment">-- Copyright   :  (c) University of Glasgow 2006</span><span>
</span><span id="line-10"></span><span class="hs-comment">-- License     :  BSD-style (see the file LICENSE)</span><span>
</span><span id="line-11"></span><span class="hs-comment">--</span><span>
</span><span id="line-12"></span><span class="hs-comment">-- Maintainer  :  Esa Ilari Vuokko &lt;ei@vuokko.info&gt;</span><span>
</span><span id="line-13"></span><span class="hs-comment">-- Stability   :  provisional</span><span>
</span><span id="line-14"></span><span class="hs-comment">-- Portability :  portable</span><span>
</span><span id="line-15"></span><span class="hs-comment">--</span><span>
</span><span id="line-16"></span><span class="hs-comment">-- A collection of FFI declarations for interfacing with Win32 Console API</span><span>
</span><span id="line-17"></span><span class="hs-comment">--</span><span>
</span><span id="line-18"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-19"></span><span>
</span><span id="line-20"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">System.Win32.Console</span><span> </span><span class="hs-special">(</span><span>
</span><span id="line-21"></span><span>        </span><span class="hs-comment">-- * Console mode</span><span>
</span><span id="line-22"></span><span>        </span><span class="hs-identifier">getConsoleMode</span><span class="hs-special">,</span><span>
</span><span id="line-23"></span><span>        </span><span class="hs-identifier">setConsoleMode</span><span class="hs-special">,</span><span>
</span><span id="line-24"></span><span>        </span><span class="hs-identifier">eNABLE_ECHO_INPUT</span><span class="hs-special">,</span><span>
</span><span id="line-25"></span><span>        </span><span class="hs-identifier">eNABLE_EXTENDED_FLAGS</span><span class="hs-special">,</span><span>
</span><span id="line-26"></span><span>        </span><span class="hs-identifier">eNABLE_INSERT_MODE</span><span class="hs-special">,</span><span>
</span><span id="line-27"></span><span>        </span><span class="hs-identifier">eNABLE_LINE_INPUT</span><span class="hs-special">,</span><span>
</span><span id="line-28"></span><span>        </span><span class="hs-identifier">eNABLE_MOUSE_INPUT</span><span class="hs-special">,</span><span>
</span><span id="line-29"></span><span>        </span><span class="hs-identifier">eNABLE_PROCESSED_INPUT</span><span class="hs-special">,</span><span>
</span><span id="line-30"></span><span>        </span><span class="hs-identifier">eNABLE_QUICK_EDIT_MODE</span><span class="hs-special">,</span><span>
</span><span id="line-31"></span><span>        </span><span class="hs-identifier">eNABLE_WINDOW_INPUT</span><span class="hs-special">,</span><span>
</span><span id="line-32"></span><span>        </span><span class="hs-identifier">eNABLE_VIRTUAL_TERMINAL_INPUT</span><span class="hs-special">,</span><span>
</span><span id="line-33"></span><span>        </span><span class="hs-identifier">eNABLE_PROCESSED_OUTPUT</span><span class="hs-special">,</span><span>
</span><span id="line-34"></span><span>        </span><span class="hs-identifier">eNABLE_WRAP_AT_EOL_OUTPUT</span><span class="hs-special">,</span><span>
</span><span id="line-35"></span><span>        </span><span class="hs-identifier">eNABLE_VIRTUAL_TERMINAL_PROCESSING</span><span class="hs-special">,</span><span>
</span><span id="line-36"></span><span>        </span><span class="hs-identifier">dISABLE_NEWLINE_AUTO_RETURN</span><span class="hs-special">,</span><span>
</span><span id="line-37"></span><span>        </span><span class="hs-identifier">eNABLE_LVB_GRID_WORLDWIDE</span><span class="hs-special">,</span><span>
</span><span id="line-38"></span><span>        </span><span class="hs-comment">-- * Console code pages</span><span>
</span><span id="line-39"></span><span>        </span><span class="hs-identifier">getConsoleCP</span><span class="hs-special">,</span><span>
</span><span id="line-40"></span><span>        </span><span class="hs-identifier">setConsoleCP</span><span class="hs-special">,</span><span>
</span><span id="line-41"></span><span>        </span><span class="hs-identifier">getConsoleOutputCP</span><span class="hs-special">,</span><span>
</span><span id="line-42"></span><span>        </span><span class="hs-identifier">setConsoleOutputCP</span><span class="hs-special">,</span><span>
</span><span id="line-43"></span><span>        </span><span class="hs-comment">-- * Ctrl events</span><span>
</span><span id="line-44"></span><span>        </span><span class="hs-identifier">CtrlEvent</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">cTRL_C_EVENT</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">cTRL_BREAK_EVENT</span><span class="hs-special">,</span><span>
</span><span id="line-45"></span><span>        </span><span class="hs-identifier">generateConsoleCtrlEvent</span><span class="hs-special">,</span><span>
</span><span id="line-46"></span><span>        </span><span class="hs-comment">-- * Command line</span><span>
</span><span id="line-47"></span><span>        </span><span class="hs-identifier">commandLineToArgv</span><span class="hs-special">,</span><span>
</span><span id="line-48"></span><span>        </span><span class="hs-comment">-- * Screen buffer</span><span>
</span><span id="line-49"></span><span>        </span><span class="hs-identifier">CONSOLE_SCREEN_BUFFER_INFO</span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-50"></span><span>        </span><span class="hs-identifier">COORD</span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-51"></span><span>        </span><span class="hs-identifier">SMALL_RECT</span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-52"></span><span>        </span><span class="hs-identifier">getConsoleScreenBufferInfo</span><span class="hs-special">,</span><span>
</span><span id="line-53"></span><span>        </span><span class="hs-identifier">getCurrentConsoleScreenBufferInfo</span><span>
</span><span id="line-54"></span><span>  </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span class="hs-cpp">



#include &quot;windows_cconv.h&quot;
</span><span>
</span><span id="line-60"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">System.Win32.Types</span><span>
</span><span id="line-61"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Graphics.Win32.Misc</span><span>
</span><span id="line-62"></span><span>
</span><span id="line-63"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Foreign.C.Types</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">CInt</span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-64"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Foreign.C.String</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">withCWString</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">CWString</span><span class="hs-special">)</span><span>
</span><span id="line-65"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Foreign.Ptr</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">Ptr</span><span class="hs-special">)</span><span>
</span><span id="line-66"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Foreign.Storable</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">Storable</span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-67"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Foreign.Marshal.Array</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">peekArray</span><span class="hs-special">)</span><span>
</span><span id="line-68"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Foreign.Marshal.Alloc</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">alloca</span><span class="hs-special">)</span><span>
</span><span id="line-69"></span><span>
</span><span id="line-70"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h GetConsoleMode&quot;</span><span>
</span><span id="line-71"></span><span>        </span><span class="hs-identifier">c_GetConsoleMode</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HANDLE</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">LPDWORD</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">BOOL</span><span>
</span><span id="line-72"></span><span>
</span><span id="line-73"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h SetConsoleMode&quot;</span><span>
</span><span id="line-74"></span><span>        </span><span class="hs-identifier">c_SetConsoleMode</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HANDLE</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">DWORD</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">BOOL</span><span>
</span><span id="line-75"></span><span>
</span><span id="line-76"></span><span class="hs-identifier">getConsoleMode</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HANDLE</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">DWORD</span><span>
</span><span id="line-77"></span><span class="hs-identifier">getConsoleMode</span><span> </span><span class="hs-identifier">h</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">alloca</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span class="hs-identifier">ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-78"></span><span>    </span><span class="hs-identifier">failIfFalse_</span><span> </span><span class="hs-string">&quot;GetConsoleMode&quot;</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">c_GetConsoleMode</span><span> </span><span class="hs-identifier">h</span><span> </span><span class="hs-identifier">ptr</span><span>
</span><span id="line-79"></span><span>    </span><span class="hs-identifier">peek</span><span> </span><span class="hs-identifier">ptr</span><span>
</span><span id="line-80"></span><span>
</span><span id="line-81"></span><span class="hs-identifier">setConsoleMode</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HANDLE</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">DWORD</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-82"></span><span class="hs-identifier">setConsoleMode</span><span> </span><span class="hs-identifier">h</span><span> </span><span class="hs-identifier">mode</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">failIfFalse_</span><span> </span><span class="hs-string">&quot;SetConsoleMode&quot;</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">c_SetConsoleMode</span><span> </span><span class="hs-identifier">h</span><span> </span><span class="hs-identifier">mode</span><span>
</span><span id="line-83"></span><span>
</span><span id="line-84"></span><span class="hs-identifier">eNABLE_ECHO_INPUT</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">eNABLE_EXTENDED_FLAGS</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">eNABLE_INSERT_MODE</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">eNABLE_LINE_INPUT</span><span class="hs-special">,</span><span>
</span><span id="line-85"></span><span>    </span><span class="hs-identifier">eNABLE_MOUSE_INPUT</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">eNABLE_PROCESSED_INPUT</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">eNABLE_QUICK_EDIT_MODE</span><span class="hs-special">,</span><span>
</span><span id="line-86"></span><span>    </span><span class="hs-identifier">eNABLE_WINDOW_INPUT</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">eNABLE_VIRTUAL_TERMINAL_INPUT</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">eNABLE_PROCESSED_OUTPUT</span><span class="hs-special">,</span><span>
</span><span id="line-87"></span><span>    </span><span class="hs-identifier">eNABLE_WRAP_AT_EOL_OUTPUT</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">eNABLE_VIRTUAL_TERMINAL_PROCESSING</span><span class="hs-special">,</span><span>
</span><span id="line-88"></span><span>    </span><span class="hs-identifier">dISABLE_NEWLINE_AUTO_RETURN</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">eNABLE_LVB_GRID_WORLDWIDE</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">DWORD</span><span>
</span><span id="line-89"></span><span class="hs-identifier">eNABLE_ECHO_INPUT</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-number">4</span><span>
</span><span id="line-90"></span><span class="hs-identifier">eNABLE_EXTENDED_FLAGS</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-number">128</span><span>
</span><span id="line-91"></span><span class="hs-identifier">eNABLE_INSERT_MODE</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-number">32</span><span>
</span><span id="line-92"></span><span class="hs-identifier">eNABLE_LINE_INPUT</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-number">2</span><span>
</span><span id="line-93"></span><span class="hs-identifier">eNABLE_MOUSE_INPUT</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-number">16</span><span>
</span><span id="line-94"></span><span class="hs-identifier">eNABLE_PROCESSED_INPUT</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-number">1</span><span>
</span><span id="line-95"></span><span class="hs-identifier">eNABLE_QUICK_EDIT_MODE</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-number">64</span><span>
</span><span id="line-96"></span><span class="hs-identifier">eNABLE_WINDOW_INPUT</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-number">8</span><span>
</span><span id="line-97"></span><span class="hs-identifier">eNABLE_VIRTUAL_TERMINAL_INPUT</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-number">512</span><span>
</span><span id="line-98"></span><span class="hs-identifier">eNABLE_PROCESSED_OUTPUT</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-number">1</span><span>
</span><span id="line-99"></span><span class="hs-identifier">eNABLE_WRAP_AT_EOL_OUTPUT</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-number">2</span><span>
</span><span id="line-100"></span><span class="hs-identifier">eNABLE_VIRTUAL_TERMINAL_PROCESSING</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-number">4</span><span>
</span><span id="line-101"></span><span class="hs-identifier">dISABLE_NEWLINE_AUTO_RETURN</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-number">8</span><span>
</span><span id="line-102"></span><span class="hs-identifier">eNABLE_LVB_GRID_WORLDWIDE</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-number">16</span><span>
</span><span id="line-103"></span><span>
</span><span id="line-104"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h GetConsoleCP&quot;</span><span>
</span><span id="line-105"></span><span>        </span><span class="hs-identifier">getConsoleCP</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">UINT</span><span>
</span><span id="line-106"></span><span>
</span><span id="line-107"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h SetConsoleCP&quot;</span><span>
</span><span id="line-108"></span><span>        </span><span class="hs-identifier">setConsoleCP</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">UINT</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-109"></span><span>
</span><span id="line-110"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h GetConsoleOutputCP&quot;</span><span>
</span><span id="line-111"></span><span>        </span><span class="hs-identifier">getConsoleOutputCP</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">UINT</span><span>
</span><span id="line-112"></span><span>
</span><span id="line-113"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h SetConsoleOutputCP&quot;</span><span>
</span><span id="line-114"></span><span>        </span><span class="hs-identifier">setConsoleOutputCP</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">UINT</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-115"></span><span>
</span><span id="line-116"></span><span class="hs-keyword">type</span><span> </span><span class="hs-identifier">CtrlEvent</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">DWORD</span><span>
</span><span id="line-117"></span><span class="hs-identifier">cTRL_C_EVENT</span><span>       </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">CtrlEvent</span><span>
</span><span id="line-118"></span><span class="hs-identifier">cTRL_C_EVENT</span><span>       </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">0</span><span>
</span><span id="line-119"></span><span class="hs-identifier">cTRL_BREAK_EVENT</span><span>   </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">CtrlEvent</span><span>
</span><span id="line-120"></span><span class="hs-identifier">cTRL_BREAK_EVENT</span><span>   </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">1</span><span>
</span><span id="line-121"></span><span>
</span><span id="line-122"></span><span class="hs-pragma">{-# LINE 121 &quot;libraries\\Win32\\System\\Win32\\Console.hsc&quot; #-}</span><span>
</span><span id="line-121"></span><span>
</span><span id="line-122"></span><span class="hs-identifier">generateConsoleCtrlEvent</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">CtrlEvent</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">DWORD</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-123"></span><span class="hs-identifier">generateConsoleCtrlEvent</span><span> </span><span class="hs-identifier">e</span><span> </span><span class="hs-identifier">p</span><span>
</span><span id="line-124"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">failIfFalse_</span><span>
</span><span id="line-125"></span><span>        </span><span class="hs-string">&quot;generateConsoleCtrlEvent&quot;</span><span>
</span><span id="line-126"></span><span>        </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">c_GenerateConsoleCtrlEvent</span><span> </span><span class="hs-identifier">e</span><span> </span><span class="hs-identifier">p</span><span>
</span><span id="line-127"></span><span>
</span><span id="line-128"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">safe</span><span> </span><span class="hs-string">&quot;windows.h GenerateConsoleCtrlEvent&quot;</span><span>
</span><span id="line-129"></span><span>    </span><span class="hs-identifier">c_GenerateConsoleCtrlEvent</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">CtrlEvent</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">DWORD</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">BOOL</span><span>
</span><span id="line-130"></span><span>
</span><span id="line-131"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;Shellapi.h CommandLineToArgvW&quot;</span><span>
</span><span id="line-132"></span><span>     </span><span class="hs-identifier">c_CommandLineToArgvW</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">CWString</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Ptr</span><span> </span><span class="hs-identifier">CInt</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">Ptr</span><span> </span><span class="hs-identifier">CWString</span><span class="hs-special">)</span><span>
</span><span id="line-133"></span><span>
</span><span id="line-134"></span><span class="hs-comment">-- | This function can be used to parse commandline arguments and return</span><span>
</span><span id="line-135"></span><span class="hs-comment">--   the split up arguments as elements in a list.</span><span>
</span><span id="line-136"></span><span class="hs-identifier">commandLineToArgv</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">String</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-special">[</span><span class="hs-identifier">String</span><span class="hs-special">]</span><span>
</span><span id="line-137"></span><span class="hs-identifier">commandLineToArgv</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">return</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-138"></span><span class="hs-identifier">commandLineToArgv</span><span> </span><span class="hs-identifier">arg</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-139"></span><span>  </span><span class="hs-keyword">do</span><span> </span><span class="hs-identifier">withCWString</span><span> </span><span class="hs-identifier">arg</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span class="hs-identifier">c_arg</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-140"></span><span>       </span><span class="hs-identifier">alloca</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span class="hs-identifier">c_size</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-141"></span><span>         </span><span class="hs-identifier">res</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">c_CommandLineToArgvW</span><span> </span><span class="hs-identifier">c_arg</span><span> </span><span class="hs-identifier">c_size</span><span>
</span><span id="line-142"></span><span>         </span><span class="hs-identifier">size</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">peek</span><span> </span><span class="hs-identifier">c_size</span><span>
</span><span id="line-143"></span><span>         </span><span class="hs-identifier">args</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">peekArray</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">fromIntegral</span><span> </span><span class="hs-identifier">size</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">res</span><span>
</span><span id="line-144"></span><span>         </span><span class="hs-identifier">_</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">localFree</span><span> </span><span class="hs-identifier">res</span><span>
</span><span id="line-145"></span><span>         </span><span class="hs-identifier">mapM</span><span> </span><span class="hs-identifier">peekTString</span><span> </span><span class="hs-identifier">args</span><span>
</span><span id="line-146"></span><span>
</span><span id="line-147"></span><span class="hs-keyword">data</span><span> </span><span class="hs-identifier">CONSOLE_SCREEN_BUFFER_INFO</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">CONSOLE_SCREEN_BUFFER_INFO</span><span>
</span><span id="line-148"></span><span>    </span><span class="hs-special">{</span><span> </span><span class="hs-identifier">dwSize</span><span>              </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">COORD</span><span>
</span><span id="line-149"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">dwCursorPosition</span><span>    </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">COORD</span><span>
</span><span id="line-150"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">wAttributes</span><span>         </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">WORD</span><span>
</span><span id="line-151"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">srWindow</span><span>            </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">SMALL_RECT</span><span>
</span><span id="line-152"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">dwMaximumWindowSize</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">COORD</span><span>
</span><span id="line-153"></span><span>    </span><span class="hs-special">}</span><span> </span><span class="hs-keyword">deriving</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">Show</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">Eq</span><span class="hs-special">)</span><span>
</span><span id="line-154"></span><span>
</span><span id="line-155"></span><span class="hs-keyword">instance</span><span> </span><span class="hs-identifier">Storable</span><span> </span><span class="hs-identifier">CONSOLE_SCREEN_BUFFER_INFO</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-156"></span><span>    </span><span class="hs-identifier">sizeOf</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">const</span><span> </span><span class="hs-special">(</span><span class="hs-number">22</span><span class="hs-special">)</span><span>
</span><span id="line-157"></span><span class="hs-pragma">{-# LINE 157 &quot;libraries\\Win32\\System\\Win32\\Console.hsc&quot; #-}</span><span>
</span><span id="line-157"></span><span>    </span><span class="hs-identifier">alignment</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-number">2</span><span>
</span><span id="line-158"></span><span class="hs-pragma">{-# LINE 158 &quot;libraries\\Win32\\System\\Win32\\Console.hsc&quot; #-}</span><span>
</span><span id="line-158"></span><span>    </span><span class="hs-identifier">peek</span><span> </span><span class="hs-identifier">buf</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-159"></span><span>        </span><span class="hs-identifier">dwSize'</span><span>              </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">peekByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">0</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">buf</span><span>
</span><span id="line-160"></span><span class="hs-pragma">{-# LINE 160 &quot;libraries\\Win32\\System\\Win32\\Console.hsc&quot; #-}</span><span>
</span><span id="line-160"></span><span>        </span><span class="hs-identifier">dwCursorPosition'</span><span>    </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">peekByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">4</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">buf</span><span>
</span><span id="line-161"></span><span class="hs-pragma">{-# LINE 161 &quot;libraries\\Win32\\System\\Win32\\Console.hsc&quot; #-}</span><span>
</span><span id="line-161"></span><span>        </span><span class="hs-identifier">wAttributes'</span><span>         </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">peekByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">8</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">buf</span><span>
</span><span id="line-162"></span><span class="hs-pragma">{-# LINE 162 &quot;libraries\\Win32\\System\\Win32\\Console.hsc&quot; #-}</span><span>
</span><span id="line-162"></span><span>        </span><span class="hs-identifier">srWindow'</span><span>            </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">peekByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">10</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">buf</span><span>
</span><span id="line-163"></span><span class="hs-pragma">{-# LINE 163 &quot;libraries\\Win32\\System\\Win32\\Console.hsc&quot; #-}</span><span>
</span><span id="line-163"></span><span>        </span><span class="hs-identifier">dwMaximumWindowSize'</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">peekByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">18</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">buf</span><span>
</span><span id="line-164"></span><span class="hs-pragma">{-# LINE 164 &quot;libraries\\Win32\\System\\Win32\\Console.hsc&quot; #-}</span><span>
</span><span id="line-164"></span><span>        </span><span class="hs-identifier">return</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">CONSOLE_SCREEN_BUFFER_INFO</span><span> </span><span class="hs-identifier">dwSize'</span><span> </span><span class="hs-identifier">dwCursorPosition'</span><span> </span><span class="hs-identifier">wAttributes'</span><span> </span><span class="hs-identifier">srWindow'</span><span> </span><span class="hs-identifier">dwMaximumWindowSize'</span><span>
</span><span id="line-165"></span><span>    </span><span class="hs-identifier">poke</span><span> </span><span class="hs-identifier">buf</span><span> </span><span class="hs-identifier">info</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-166"></span><span>        </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">0</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">buf</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">dwSize</span><span> </span><span class="hs-identifier">info</span><span class="hs-special">)</span><span>
</span><span id="line-167"></span><span class="hs-pragma">{-# LINE 167 &quot;libraries\\Win32\\System\\Win32\\Console.hsc&quot; #-}</span><span>
</span><span id="line-167"></span><span>        </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">4</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">buf</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">dwCursorPosition</span><span> </span><span class="hs-identifier">info</span><span class="hs-special">)</span><span>
</span><span id="line-168"></span><span class="hs-pragma">{-# LINE 168 &quot;libraries\\Win32\\System\\Win32\\Console.hsc&quot; #-}</span><span>
</span><span id="line-168"></span><span>        </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">8</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">buf</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">wAttributes</span><span> </span><span class="hs-identifier">info</span><span class="hs-special">)</span><span>
</span><span id="line-169"></span><span class="hs-pragma">{-# LINE 169 &quot;libraries\\Win32\\System\\Win32\\Console.hsc&quot; #-}</span><span>
</span><span id="line-169"></span><span>        </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">10</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">buf</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">srWindow</span><span> </span><span class="hs-identifier">info</span><span class="hs-special">)</span><span>
</span><span id="line-170"></span><span class="hs-pragma">{-# LINE 170 &quot;libraries\\Win32\\System\\Win32\\Console.hsc&quot; #-}</span><span>
</span><span id="line-170"></span><span>        </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">18</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">buf</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">dwMaximumWindowSize</span><span> </span><span class="hs-identifier">info</span><span class="hs-special">)</span><span>
</span><span id="line-171"></span><span class="hs-pragma">{-# LINE 171 &quot;libraries\\Win32\\System\\Win32\\Console.hsc&quot; #-}</span><span>
</span><span id="line-171"></span><span>
</span><span id="line-172"></span><span class="hs-keyword">data</span><span> </span><span class="hs-identifier">COORD</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">COORD</span><span>
</span><span id="line-173"></span><span>    </span><span class="hs-special">{</span><span> </span><span class="hs-identifier">xPos</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">SHORT</span><span>
</span><span id="line-174"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">yPos</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">SHORT</span><span>
</span><span id="line-175"></span><span>    </span><span class="hs-special">}</span><span> </span><span class="hs-keyword">deriving</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">Show</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">Eq</span><span class="hs-special">)</span><span>
</span><span id="line-176"></span><span>
</span><span id="line-177"></span><span class="hs-keyword">instance</span><span> </span><span class="hs-identifier">Storable</span><span> </span><span class="hs-identifier">COORD</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-178"></span><span>    </span><span class="hs-identifier">sizeOf</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">const</span><span> </span><span class="hs-special">(</span><span class="hs-number">4</span><span class="hs-special">)</span><span>
</span><span id="line-179"></span><span class="hs-pragma">{-# LINE 179 &quot;libraries\\Win32\\System\\Win32\\Console.hsc&quot; #-}</span><span>
</span><span id="line-179"></span><span>    </span><span class="hs-identifier">alignment</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-number">2</span><span>
</span><span id="line-180"></span><span class="hs-pragma">{-# LINE 180 &quot;libraries\\Win32\\System\\Win32\\Console.hsc&quot; #-}</span><span>
</span><span id="line-180"></span><span>    </span><span class="hs-identifier">peek</span><span> </span><span class="hs-identifier">buf</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-181"></span><span>        </span><span class="hs-identifier">x'</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">peekByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">0</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">buf</span><span>
</span><span id="line-182"></span><span class="hs-pragma">{-# LINE 182 &quot;libraries\\Win32\\System\\Win32\\Console.hsc&quot; #-}</span><span>
</span><span id="line-182"></span><span>        </span><span class="hs-identifier">y'</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">peekByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">2</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">buf</span><span>
</span><span id="line-183"></span><span class="hs-pragma">{-# LINE 183 &quot;libraries\\Win32\\System\\Win32\\Console.hsc&quot; #-}</span><span>
</span><span id="line-183"></span><span>        </span><span class="hs-identifier">return</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">COORD</span><span> </span><span class="hs-identifier">x'</span><span> </span><span class="hs-identifier">y'</span><span>
</span><span id="line-184"></span><span>    </span><span class="hs-identifier">poke</span><span> </span><span class="hs-identifier">buf</span><span> </span><span class="hs-identifier">coord</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-185"></span><span>        </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">0</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">buf</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">xPos</span><span> </span><span class="hs-identifier">coord</span><span class="hs-special">)</span><span>
</span><span id="line-186"></span><span class="hs-pragma">{-# LINE 186 &quot;libraries\\Win32\\System\\Win32\\Console.hsc&quot; #-}</span><span>
</span><span id="line-186"></span><span>        </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">2</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">buf</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">yPos</span><span> </span><span class="hs-identifier">coord</span><span class="hs-special">)</span><span>
</span><span id="line-187"></span><span class="hs-pragma">{-# LINE 187 &quot;libraries\\Win32\\System\\Win32\\Console.hsc&quot; #-}</span><span>
</span><span id="line-187"></span><span>
</span><span id="line-188"></span><span class="hs-keyword">data</span><span> </span><span class="hs-identifier">SMALL_RECT</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">SMALL_RECT</span><span>
</span><span id="line-189"></span><span>    </span><span class="hs-special">{</span><span> </span><span class="hs-identifier">leftPos</span><span>   </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">SHORT</span><span>
</span><span id="line-190"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">topPos</span><span>    </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">SHORT</span><span>
</span><span id="line-191"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">rightPos</span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">SHORT</span><span>
</span><span id="line-192"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">bottomPos</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">SHORT</span><span>
</span><span id="line-193"></span><span>    </span><span class="hs-special">}</span><span> </span><span class="hs-keyword">deriving</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">Show</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">Eq</span><span class="hs-special">)</span><span>
</span><span id="line-194"></span><span>
</span><span id="line-195"></span><span class="hs-keyword">instance</span><span> </span><span class="hs-identifier">Storable</span><span> </span><span class="hs-identifier">SMALL_RECT</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-196"></span><span>    </span><span class="hs-identifier">sizeOf</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="hs-number">8</span><span class="hs-special">)</span><span>
</span><span id="line-197"></span><span class="hs-pragma">{-# LINE 197 &quot;libraries\\Win32\\System\\Win32\\Console.hsc&quot; #-}</span><span>
</span><span id="line-197"></span><span>    </span><span class="hs-identifier">alignment</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-number">2</span><span>
</span><span id="line-198"></span><span class="hs-pragma">{-# LINE 198 &quot;libraries\\Win32\\System\\Win32\\Console.hsc&quot; #-}</span><span>
</span><span id="line-198"></span><span>    </span><span class="hs-identifier">peek</span><span> </span><span class="hs-identifier">buf</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-199"></span><span>        </span><span class="hs-identifier">left'</span><span>   </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">peekByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">0</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">buf</span><span>
</span><span id="line-200"></span><span class="hs-pragma">{-# LINE 200 &quot;libraries\\Win32\\System\\Win32\\Console.hsc&quot; #-}</span><span>
</span><span id="line-200"></span><span>        </span><span class="hs-identifier">top'</span><span>    </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">peekByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">2</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">buf</span><span>
</span><span id="line-201"></span><span class="hs-pragma">{-# LINE 201 &quot;libraries\\Win32\\System\\Win32\\Console.hsc&quot; #-}</span><span>
</span><span id="line-201"></span><span>        </span><span class="hs-identifier">right'</span><span>  </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">peekByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">4</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">buf</span><span>
</span><span id="line-202"></span><span class="hs-pragma">{-# LINE 202 &quot;libraries\\Win32\\System\\Win32\\Console.hsc&quot; #-}</span><span>
</span><span id="line-202"></span><span>        </span><span class="hs-identifier">bottom'</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">peekByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">6</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">buf</span><span>
</span><span id="line-203"></span><span class="hs-pragma">{-# LINE 203 &quot;libraries\\Win32\\System\\Win32\\Console.hsc&quot; #-}</span><span>
</span><span id="line-203"></span><span>        </span><span class="hs-identifier">return</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">SMALL_RECT</span><span> </span><span class="hs-identifier">left'</span><span> </span><span class="hs-identifier">top'</span><span> </span><span class="hs-identifier">right'</span><span> </span><span class="hs-identifier">bottom'</span><span>
</span><span id="line-204"></span><span>    </span><span class="hs-identifier">poke</span><span> </span><span class="hs-identifier">buf</span><span> </span><span class="hs-identifier">small_rect</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-205"></span><span>        </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">0</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">buf</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">leftPos</span><span> </span><span class="hs-identifier">small_rect</span><span class="hs-special">)</span><span>
</span><span id="line-206"></span><span class="hs-pragma">{-# LINE 206 &quot;libraries\\Win32\\System\\Win32\\Console.hsc&quot; #-}</span><span>
</span><span id="line-206"></span><span>        </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">2</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">buf</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">topPos</span><span> </span><span class="hs-identifier">small_rect</span><span class="hs-special">)</span><span>
</span><span id="line-207"></span><span class="hs-pragma">{-# LINE 207 &quot;libraries\\Win32\\System\\Win32\\Console.hsc&quot; #-}</span><span>
</span><span id="line-207"></span><span>        </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">4</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">buf</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">rightPos</span><span> </span><span class="hs-identifier">small_rect</span><span class="hs-special">)</span><span>
</span><span id="line-208"></span><span class="hs-pragma">{-# LINE 208 &quot;libraries\\Win32\\System\\Win32\\Console.hsc&quot; #-}</span><span>
</span><span id="line-208"></span><span>        </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">6</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">buf</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">bottomPos</span><span> </span><span class="hs-identifier">small_rect</span><span class="hs-special">)</span><span>
</span><span id="line-209"></span><span class="hs-pragma">{-# LINE 209 &quot;libraries\\Win32\\System\\Win32\\Console.hsc&quot; #-}</span><span>
</span><span id="line-209"></span><span>
</span><span id="line-210"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">safe</span><span> </span><span class="hs-string">&quot;windows.h GetConsoleScreenBufferInfo&quot;</span><span>
</span><span id="line-211"></span><span>    </span><span class="hs-identifier">c_GetConsoleScreenBufferInfo</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HANDLE</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Ptr</span><span> </span><span class="hs-identifier">CONSOLE_SCREEN_BUFFER_INFO</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">BOOL</span><span>
</span><span id="line-212"></span><span>
</span><span id="line-213"></span><span class="hs-identifier">getConsoleScreenBufferInfo</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HANDLE</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">CONSOLE_SCREEN_BUFFER_INFO</span><span>
</span><span id="line-214"></span><span class="hs-identifier">getConsoleScreenBufferInfo</span><span> </span><span class="hs-identifier">h</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">alloca</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span class="hs-identifier">ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-215"></span><span>    </span><span class="hs-identifier">failIfFalse_</span><span> </span><span class="hs-string">&quot;GetConsoleScreenBufferInfo&quot;</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">c_GetConsoleScreenBufferInfo</span><span> </span><span class="hs-identifier">h</span><span> </span><span class="hs-identifier">ptr</span><span>
</span><span id="line-216"></span><span>    </span><span class="hs-identifier">peek</span><span> </span><span class="hs-identifier">ptr</span><span>
</span><span id="line-217"></span><span>
</span><span id="line-218"></span><span class="hs-identifier">getCurrentConsoleScreenBufferInfo</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">CONSOLE_SCREEN_BUFFER_INFO</span><span>
</span><span id="line-219"></span><span class="hs-identifier">getCurrentConsoleScreenBufferInfo</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-220"></span><span>    </span><span class="hs-identifier">h</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">failIf</span><span> </span><span class="hs-special">(</span><span class="hs-operator">==</span><span> </span><span class="hs-identifier">nullHANDLE</span><span class="hs-special">)</span><span> </span><span class="hs-string">&quot;getStdHandle&quot;</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">getStdHandle</span><span> </span><span class="hs-identifier">sTD_OUTPUT_HANDLE</span><span>
</span><span id="line-221"></span><span>    </span><span class="hs-identifier">getConsoleScreenBufferInfo</span><span> </span><span class="hs-identifier">h</span><span>
</span><span id="line-222"></span></pre></body></html>